﻿package mortal.game.manager.msgTip
{
    import com.gengine.global.*;
    import com.gengine.utils.pools.*;
    import flash.display.*;
    import flash.geom.*;
    import mortal.game.view.msgtips.*;

    public class MsgTipTextImpl extends Sprite
    {
        private var _items:Array;
        private const maxLen:int = 3;

        public function MsgTipTextImpl()
        {
            this._items = [];
            mouseEnabled = false;
            mouseChildren = false;
            this.scrollRect = new Rectangle(0, 0, this.width, this.height);
            return;
        }// end function

        private function onItemHide(param1:TipsItem) : void
        {
            return;
        }// end function

        public function showInfo(param1:String, param2:String = "#ffff00", param3:int = 0) : void
        {
            var _loc_6:TipsItem = null;
            var _loc_8:TipsItem = null;
            var _loc_4:int = 0;
            var _loc_5:* = this._items.length;
            if (_loc_5 >= this.maxLen)
            {
                _loc_6 = this._items.pop();
                _loc_6.dispose();
                ObjectPool.disposeObject(_loc_6, TipsItem);
                removeChild(_loc_6);
            }
            _loc_6 = ObjectPool.getObject(TipsItem);
            _loc_6.updateData(param1, param2, param3, this.onItemHide);
            _loc_4 = 0;
            _loc_5 = this._items.length;
            var _loc_7:Boolean = false;
            while (_loc_4 < _loc_5)
            {
                
                _loc_8 = this._items[_loc_4];
                if (!_loc_8.hideAble)
                {
                    this._items.splice(_loc_4, 0, _loc_6);
                    _loc_7 = true;
                    break;
                }
                _loc_4++;
            }
            if (_loc_7 == false)
            {
                this._items.push(_loc_6);
            }
            addChild(_loc_6);
            this.updatePy();
            return;
        }// end function

        private function updatePy() : void
        {
            var _loc_1:int = 0;
            var _loc_3:int = 0;
            var _loc_4:TipsItem = null;
            var _loc_2:* = this._items.length;
            while (_loc_1 < _loc_2)
            {
                
                _loc_4 = this._items[_loc_1];
                _loc_4.y = this.height - 2 - _loc_3 - _loc_4.height;
                if (_loc_1 != 0 && !_loc_4.colorUpdated)
                {
                    _loc_4.updateColor();
                }
                _loc_4.easeIn();
                _loc_3 = _loc_3 + _loc_4.height;
                _loc_1++;
            }
            return;
        }// end function

        public function stageResize() : void
        {
            x = Global.stage.stageWidth - this.width - 15;
            y = Global.stage.stageHeight - this.height - 90;
            return;
        }// end function

        override public function get height() : Number
        {
            return 50;
        }// end function

        override public function get width() : Number
        {
            return 180;
        }// end function

    }
}
